package com.wl.spring.mapper;

import lombok.Data;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Repository //id默认类名首字母小写 userMapper
@Lazy
@Scope("prototype")
@Primary
@Data
public class UserMapper {

    public UserMapper(){
        System.out.println("==============UserMapper.userMapper=============");
    }

    @PostConstruct
    public void init(){
        //构造函数的java对象初始化，jvm的初始化
        //@PostConstruct Spring 的初始化
        //会在内部属性完成 Spring 注入之后再执行
        System.out.println("==============UserMapper.init=============");
    }

    @PreDestroy
    public void finish(){
        System.out.println("=======UserMapper.finish=========");
    }

    public void  login(String name,String pwd){
        System.out.println("==============登录============");
    }

    public String reg(){
        System.out.println("==========注册==========");
        return "注册成功";
    }

    public void query(){
        Object o = 100;
        String s = (String) o;
        System.out.println("s = " + s);
        System.out.println("==========查询==========");
    }
}
